<template>
  <div class="content">
    <site-nav />
    <head-item :state="state" :shop-detail="shopDetail" />
    <ShopPage :take-site="site" />
    <advantage-item />
    <guide-item />
    <friendly-link />
    <footer-item />
  </div>
</template>

<script>
import SiteNav from '../../layout/Nav'
import AdvantageItem from '../../layout/Advantage'
import GuideItem from '../../layout/Guide'
import FriendlyLink from '../../layout/FriendlyLink'
import FooterItem from '../../layout/Footer'
import HeadItem from '../home/component/Head.vue'
import ShopPage from '@/views/shop/component/ShopPage'
import { getShopDetail, getBrandList, getBrandProduct } from '@/api/shop'
export default {
  components: {
    SiteNav,
    AdvantageItem,
    GuideItem,
    FriendlyLink,
    FooterItem,
    HeadItem,
    ShopPage
  },
  data() {
    return {
      params: this.$route.params.data,
      state: true,
      shopDetail: {},
      site: '',
      index: 0,
      size: 1,
      lng: '',
      lag: ''
    }
  },
  watch: {
    lng(val) {
      this.lng = this.$store.getters.shopPageMap.latitude
      if (this.lng !== '') {
        this.getPagelist()
      }
    }
  },
  mounted() {
    this.getDetail()
    this.getList()
    this.getPagelist()
  },
  methods: {
    // 获取店铺信息
    getDetail() {
      getShopDetail(this.params).then(response => {
        if (response.data) {
          this.shopDetail = response.data
          console.log(this.shopDetail)
        }
      })
    },
    // 加载品牌列表
    getList() {
      getBrandList(this.params).then(res => {
        console.log(res.data)
      })
    },
    // 获取分页搜索列表
    getPagelist() {
      console.log(this.$store.getters.shopPageMap.lng)
      const data = {
        sellerId: this.params,
        childCategoryId: [
          '490231651310526464'
        ],
        lng: this.$store.getters.shopPageMap.latitude,
        lat: this.$store.getters.shopPageMap.longitude,
        sortType: 2,
        sortMethod: 'asc',
        brandId: [
          '490250698269941760'
        ],
        buyNum: 1,
        skuNumFlag: 'Y'
      }
      getBrandProduct(this.index, this.size, data).then(res => {

      })
    }
  }
}
</script>

<style>
</style>
